#ifndef PAGEDATAMONITOR_H
#define PAGEDATAMONITOR_H

#include <QWidget>
#include <QSqlRecord>
#include <QMessageBox>
#include "datamonitor.h"
#include "devicemanagement.h"

namespace Ui {
class pageDataMonitor;
}

class pageDataMonitor : public QWidget {
    Q_OBJECT

public:
    explicit pageDataMonitor(QWidget *parent = nullptr);
    ~pageDataMonitor();

private slots:
    // 修改信号参数：添加co2和pressure
    void onNewDataAvailable(int deviceId, double temperature, double humidity, double light, double co2, double pressure);
    void onQueryButtonClicked();
    void onRealTimeFilterClicked();

private:
    Ui::pageDataMonitor *ui;
    DataMonitor* m_dataMonitor;
    QList<QSqlRecord> m_realTimeCache;

    // 初始化方法
    void setupRealTimeTable();
    void setupHistoryTable();
    // 数据填充方法
    void populateHistoryTable(const QList<QSqlRecord>& records);
    void updateRealTimeDisplay(int filterId = -1);
    // 设备ID验证
    bool validateDeviceId(int deviceId);
};

#endif // PAGEDATAMONITOR_H
